<template>
  <el-dialog   :visible.sync="visible" :title="title"  width="600px"  :before-close="handleClose" :close-on-click-modal="false">

       <el-form ref="form" :model="bill" :rules="rules" label-width="80px">
        <el-form-item label="故障现象" >
          <el-input v-model="bill.fault"  type="textarea" disabled="true" />
        </el-form-item>
        <el-form-item label="工作内容" >
          <el-input v-model="bill.workcontent"  type="textarea"  disabled="true"/>
        </el-form-item>
        <el-form-item label="工作结果" >
          <el-input v-model="bill.workresult"  type="textarea"  disabled="true"/>
        </el-form-item>
           <el-form-item label="附件" >
              <div v-for="(item,index) in imglist" :key="index" >
              <el-link  type="primary" :href="imglist[index]" target="_blank">附件-{{index}}</el-link>
          </div>
        </el-form-item>
        <el-form-item label="配件名称" >
          <el-input v-model="bill.partsname"    disabled="true"/>
        </el-form-item>
        <el-form-item label="配件型号" >
          <el-input v-model="bill.partsmodel"   disabled="true" />
        </el-form-item>



         <el-form-item label="服务评价" prop="evaluate">
              <el-radio-group v-model="bill.evaluate">
                <el-radio
                  v-for="dict in evaluateOptions"
                  :key="dict.dictValue"
                  :label="dict.dictValue"
                >{{dict.dictLabel}}</el-radio>
              </el-radio-group>
           </el-form-item>
          <el-form-item label="建议" prop="suggest">
            <el-input v-model="bill.suggest"  type="textarea"  placeholder="请输入建议"  maxlength="500"/>
          </el-form-item>
       </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitForm1"  v-preventReClick="3000">提交评价</el-button>
          <el-button @click="cancel1">取 消</el-button>
        </div>
  </el-dialog>
</template>

<script>
  import {getBillBySendOrderId,updateBill} from "@/api/zyx/bill";
  import { onlyupd } from "@/api/zyx/sendorder";
  export default {
     data() {
       return {
         evaluateOptions:[],
         imglist:[],
         id:null,
         addcost:null,
          bill:{},
        visible: false,
        title:'',
         // 表单参数
         sendorder: {},
         rules: {
           addcost: [
             { required: true, message: "附加费用不能为空", trigger: "change" }
           ],
         },
         from:{},
         }
     },
     created() {
       this.getDicts("zyx_evaluate").then(response => {
         this.evaluateOptions = response.data;
       });
     },
     methods:{
       checkCost(cost){
           return RegExp(/^(([1-9]{1}\d*)|(0{1}))(\.\d{1,2})?$/).test(cost);
       },
       getname(){
         this.getDicts("zyx_devicetype").then(response => {
           this.devicetypeOptions = response.data;
           // this.zyxDevice=response.data.zyxDevice

           this.devicetypename= this.selectDictLabel(this.devicetypeOptions, this.zyxDevice.devicetype);

         });
       },
       getbilldetail(){
         getBillBySendOrderId(this.sendorder.id).then(response => {
           this.bill = response.data;
            this.imglist=this.bill.files.split(',');
         });
       },

       // 表单重置
       reset() {
         this.form = {
           id: null,
           addcost: null,
         };
         this.addcost='',
         this.resetForm("form1");
       },
       // 取消按钮
       cancel1() {
         this.visible = false;
         this.reset();
       },
       /** 提交按钮 */
       submitForm1() {
         this.$refs["form"].validate(valid => {
           if (valid) {
            updateBill(this.bill).then(response => {
              this.msgSuccess("修改成功");
              this.visible = false;
              this.$parent.getList();
            });
           }
         });
       },
     }
    }
</script>

<style>
   .tab  tr td { border:1px solid #000000; }
   .tdcontent{ text-align:left;width: 220px;padding-left: 10px;}
   .tdtitle{text-align: right;width: 120px;padding-right: 10px;font-weight: bold;}
   .tab  {  min-height: 40px; line-height: 40px; text-align: center; border-collapse: collapse; }
</style>
